package com.flying.function;

import reactor.core.publisher.Flux;
import reactor.util.function.Tuples;

public class Runner {

    public Flux<Integer> generateFibonacciWithTuples() {
        return Flux.generate(
                () -> Tuples.of(0, 1),
                (state, sink) -> {
                    sink.next(state.getT2());
                    ;
                    return Tuples.of(state.getT2(), state.getT1() + state.getT2());
                });
    }

    public static void main(String[] args) {
        Runner runner = new Runner();
        runner.generateFibonacciWithTuples()
                .log()
                .subscribe(i -> {
                        System.out.println(i);
                });
    }
}

